<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="产业集群" prop="parkIndustry">
        <el-select v-model="queryParams.parkIndustry"  placeholder="请选择产业集群" clearable>
          <el-option
            v-for="dict in dict.type.industry_orientation"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="公寓名称" prop="apartmentName">
        <el-input
          v-model="queryParams.apartmentName"
          placeholder="请输入公寓名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="所属城市" prop="cityId">
        <el-select v-model="queryParams.provinceId" placeholder="请选择省份"
                   @change="getCityList(queryParams.provinceId)"
                   style="width: 108px"
                   clearable>
          <el-option
            v-for="dict in provinces"
            :key="dict.id"
            :label="dict.name"
            :value="dict.id"
          />
        </el-select>
        <el-select v-model="queryParams.cityId" placeholder="请选择城市"
                   :disabled="queryParams.provinceId==null||queryParams.provinceId===''"
                   style="width: 107px"
                   clearable>
          <el-option
            v-for="dict in citys"
            :key="dict.id"
            :label="dict.name"
            :value="dict.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="园区类型" prop="parkType">
        <el-select v-model="queryParams.parkType" placeholder="请选择园区类型" clearable>
          <el-option
            v-for="dict in dict.type.park_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
<!--      <el-form-item label="发布类型" prop="releaseType">-->
<!--        <el-select v-model="queryParams.releaseType" placeholder="请选择发布类型" clearable>-->
<!--          <el-option-->
<!--            v-for="dict in dict.type.announce_type"-->
<!--            :key="dict.value"-->
<!--            :label="dict.label"-->
<!--            :value="dict.value"-->
<!--          />-->
<!--        </el-select>-->
<!--      </el-form-item>-->
      <el-form-item label="需求类型" prop="supplyType">
        <el-select v-model="queryParams.supplyType" placeholder="请选择需求类型" clearable>
          <el-option
            v-for="dict in dict.type.need_mode"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="预算" prop="apartmentLeasePrice">
        <el-select v-model="queryParams.apartmentLeasePrice" placeholder="请选择预算" clearable>
          <el-option
            v-for="dict in dict.type.rental_price"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
<!--      <el-form-item label="出售价格" prop="apartmentSellPrice">
        <el-input
          v-model="queryParams.apartmentSellPrice"
          placeholder="请输入出售价格"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="总面积" prop="apartmentAllSize">
        <el-input
          v-model="queryParams.apartmentAllSize"
          placeholder="请输入总面积"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="空置面积" prop="apartmentFreeSize">
        <el-input
          v-model="queryParams.apartmentFreeSize"
          placeholder="请输入空置面积"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="公寓楼号" prop="apartmentNumber">
        <el-input
          v-model="queryParams.apartmentNumber"
          placeholder="请输入公寓楼号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="单间公寓面积" prop="apartmentRoomSize">
        <el-input
          v-model="queryParams.apartmentRoomSize"
          placeholder="请输入单间公寓面积"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="户型" prop="apartmentHouse">
        <el-select v-model="queryParams.apartmentHouse" placeholder="请选择户型" clearable>
          <el-option
            v-for="dict in dict.type.park_apartment"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="朝向" prop="apartmentDirection">
        <el-input
          v-model="queryParams.apartmentDirection"
          placeholder="请输入朝向"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="装修程度" prop="apartmentRenova">
        <el-select v-model="queryParams.apartmentRenova" placeholder="请选择装修程度" clearable>
          <el-option
            v-for="dict in dict.type.degree_of_decoration"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="客梯" prop="apartmentElevatorPeople">
        <el-select v-model="queryParams.apartmentElevatorPeople" placeholder="请选择客梯" clearable>
          <el-option
            v-for="dict in dict.type.sys_have_not"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="客梯负载" prop="apartmentElevatorPeopleLoad">
        <el-input
          v-model="queryParams.apartmentElevatorPeopleLoad"
          placeholder="请输入客梯负载"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="货梯" prop="apartmentElevatorCargo">
        <el-select v-model="queryParams.apartmentElevatorCargo" placeholder="请选择货梯" clearable>
          <el-option
            v-for="dict in dict.type.sys_have_not"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="货梯负载" prop="apartmentElevatorCargoLoad">
        <el-input
          v-model="queryParams.apartmentElevatorCargoLoad"
          placeholder="请输入货梯负载"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item label="应急系统" prop="apartmentEmergency">
        <el-select v-model="queryParams.apartmentEmergency" placeholder="是否应急系统" clearable>
          <el-option
            v-for="dict in dict.type.sys_have_not"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="供暖" prop="apartmentHeating">
        <el-select v-model="queryParams.apartmentHeating" placeholder="请选择供暖" clearable>
          <el-option
            v-for="dict in dict.type.heating_system"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="制冷" prop="apartmentRefrig">
        <el-select v-model="queryParams.apartmentRefrig" placeholder="请选择制冷" clearable>
          <el-option
            v-for="dict in dict.type.refrigerating_system"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="燃气" prop="apartmentGas">
        <el-select v-model="queryParams.apartmentGas" placeholder="请选择燃气" clearable>
          <el-option
            v-for="dict in dict.type.gas_system"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="审核状态" prop="approvalState">
        <el-select v-model="queryParams.approvalState" placeholder="请选择审核状态" clearable>
          <el-option
            v-for="dict in dict.type.audit_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
<!--
      <el-form-item label="新风系统" prop="apartmentNather">
        <el-select v-model="queryParams.apartmentNather" placeholder="请选择新风系统" clearable>
          <el-option
            v-for="dict in dict.type.sys_have_not"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="电" prop="apartmentPower">
        <el-input
          v-model="queryParams.apartmentPower"
          placeholder="请输入电"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="水" prop="apartmentWater">
        <el-select v-model="queryParams.apartmentWater" placeholder="请选择水" clearable>
          <el-option
            v-for="dict in dict.type.water_system"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="需求面积" prop="apartmentNeedSize">
        <el-input
          v-model="queryParams.apartmentNeedSize"
          placeholder="请输入需求面积"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="周边交通" prop="apartmentTraffic">
        <el-input
          v-model="queryParams.apartmentTraffic"
          placeholder="请输入周边交通"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="区域位置" prop="parkAreaAddress">
        <el-input
          v-model="queryParams.parkAreaAddress"
          placeholder="请输入区域位置"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="公交" prop="parkBus">
        <el-select v-model="queryParams.parkBus" placeholder="请选择公交" clearable>
          <el-option
            v-for="dict in dict.type.traffic_distance"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="地铁" prop="parkMetro">
        <el-select v-model="queryParams.parkMetro" placeholder="请选择地铁" clearable>
          <el-option
            v-for="dict in dict.type.traffic_distance"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="所属城市ID" prop="cityId">
        <el-input
          v-model="queryParams.cityId"
          placeholder="请输入所属城市ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="浏览量" prop="pageView">
        <el-input
          v-model="queryParams.pageView"
          placeholder="请输入浏览量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否收藏0否1是" prop="collectState">
        <el-input
          v-model="queryParams.collectState"
          placeholder="请输入是否收藏0否1是"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否明星推荐0否1是" prop="recState">
        <el-input
          v-model="queryParams.recState"
          placeholder="请输入是否明星推荐0否1是"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预定状态0未预定1已预定" prop="reserveState">
        <el-input
          v-model="queryParams.reserveState"
          placeholder="请输入预定状态0未预定1已预定"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="明星推荐状态0否1是" prop="recomState">
        <el-select v-model="queryParams.recomState" placeholder="请选择明星推荐状态0否1是" clearable>
          <el-option
            v-for="dict in dict.type.sys_yes_no"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="联系人" prop="contactName">
        <el-input
          v-model="queryParams.contactName"
          placeholder="请输入联系人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="联系方式" prop="servicePhone">
        <el-input
          v-model="queryParams.servicePhone"
          placeholder="请输入联系方式"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="联系方式" prop="contactPhone">
        <el-input
          v-model="queryParams.contactPhone"
          placeholder="请输入联系方式"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="发布人用户ID" prop="supplyUserId">
        <el-input
          v-model="queryParams.supplyUserId"
          placeholder="请输入发布人用户ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="审核状态：0待审核1审核通过2审核失败" prop="approvalState">
        <el-input
          v-model="queryParams.approvalState"
          placeholder="请输入审核状态：0待审核1审核通过2审核失败"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="审核备注" prop="approvalNote">
        <el-input
          v-model="queryParams.approvalNote"
          placeholder="请输入审核备注"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="园区ID" prop="parkId">
        <el-input
          v-model="queryParams.parkId"
          placeholder="请输入园区ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="备注" prop="note">
        <el-input
          v-model="queryParams.note"
          placeholder="请输入备注"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="排序" prop="sort">
        <el-input
          v-model="queryParams.sort"
          placeholder="请输入排序"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="状态0有效1失效" prop="state">
        <el-input
          v-model="queryParams.state"
          placeholder="请输入状态0有效1失效"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否删除0否1是" prop="dr">
        <el-input
          v-model="queryParams.dr"
          placeholder="请输入是否删除0否1是"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否置顶0：否1：是" prop="top">
        <el-select v-model="queryParams.top" placeholder="请选择是否置顶0：否1：是" clearable>
          <el-option
            v-for="dict in dict.type.sys_yes_no"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
-->
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['myIndustry:apartment:add']"
        >新增</el-button>
      </el-col>
<!--      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['myIndustry:apartment:edit']"
        >修改</el-button>
      </el-col>
      -->
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['myIndustry:apartment:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['myIndustry:apartment:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="apartmentList" @selection-change="handleSelectionChange" height="410" fixed>
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="用户ID" align="center" prop="id" />
      <el-table-column label="公寓名称" align="center" prop="apartmentName" />
      <el-table-column label="需求类型" align="center" prop="supplyType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.need_mode" :value="scope.row.supplyType ? scope.row.supplyType.split(',') : []"/>
        </template>
      </el-table-column>
      <el-table-column label="预算" align="center" prop="apartmentLeasePrice" />
      <el-table-column label="预期价格" align="center" prop="apartmentSellPrice" />
      <el-table-column label="建筑面积" align="center" prop="apartmentAllSize" />
      <el-table-column label="空置面积" align="center" prop="apartmentFreeSize" />
      <el-table-column label="关联园区" align="center" prop="parkType" />
      <el-table-column label="所属城市" align="center" prop="cityName" />

<!--
      <el-table-column label="总面积" align="center" prop="apartmentAllSize" />
      <el-table-column label="空置面积" align="center" prop="apartmentFreeSize" />
      <el-table-column label="公寓楼号" align="center" prop="apartmentNumber" />
      <el-table-column label="单间公寓面积" align="center" prop="apartmentRoomSize" />
      <el-table-column label="户型" align="center" prop="apartmentHouse">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.park_apartment" :value="scope.row.apartmentHouse"/>
        </template>
      </el-table-column>
      <el-table-column label="朝向" align="center" prop="apartmentDirection" />
      <el-table-column label="装修程度" align="center" prop="apartmentRenova">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.degree_of_decoration" :value="scope.row.apartmentRenova"/>
        </template>
      </el-table-column>
      <el-table-column label="客梯" align="center" prop="apartmentElevatorPeople">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_have_not" :value="scope.row.apartmentElevatorPeople"/>
        </template>
      </el-table-column>
      <el-table-column label="客梯负载" align="center" prop="apartmentElevatorPeopleLoad" />
      <el-table-column label="货梯" align="center" prop="apartmentElevatorCargo">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_have_not" :value="scope.row.apartmentElevatorCargo"/>
        </template>
      </el-table-column>
      <el-table-column label="货梯负载" align="center" prop="apartmentElevatorCargoLoad" />
      <el-table-column label="消防设施" align="center" prop="apartmentFireControl">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.fire_fighting_device" :value="scope.row.apartmentFireControl ? scope.row.apartmentFireControl.split(',') : []"/>
        </template>
      </el-table-column>
-->
      <el-table-column label="应急系统" align="center" prop="apartmentEmergency">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_have_not" :value="scope.row.apartmentEmergency"/>
        </template>
      </el-table-column>
      <el-table-column label="供暖" align="center" prop="apartmentHeating">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.heating_system" :value="scope.row.apartmentHeating"/>
        </template>
      </el-table-column>
      <el-table-column label="制冷" align="center" prop="apartmentRefrig">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.refrigerating_system" :value="scope.row.apartmentRefrig"/>
        </template>
      </el-table-column>
<!--      <el-table-column label="新风系统" align="center" prop="apartmentNather">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_have_not" :value="scope.row.apartmentNather"/>
        </template>
      </el-table-column>
      <el-table-column label="电" align="center" prop="apartmentPower" />-->
      <el-table-column label="燃气" align="center" prop="apartmentGas">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.gas_system" :value="scope.row.apartmentGas ? scope.row.apartmentGas.split(',') : []"/>
        </template>
      </el-table-column>
      <el-table-column label="供水" align="center" prop="apartmentWater">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.water_system" :value="scope.row.apartmentWater"/>
        </template>
      </el-table-column>
<!--      <el-table-column label="需求面积" align="center" prop="apartmentNeedSize" />
      <el-table-column label="周边交通" align="center" prop="apartmentTraffic" />
      <el-table-column label="园区类别" align="center" prop="parkType" />
      <el-table-column label="区域位置" align="center" prop="parkAreaAddress" />
      <el-table-column label="公交" align="center" prop="parkBus">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.traffic_distance" :value="scope.row.parkBus"/>
        </template>
      </el-table-column>
      <el-table-column label="地铁" align="center" prop="parkMetro">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.traffic_distance" :value="scope.row.parkMetro"/>
        </template>
      </el-table-column>
      <el-table-column label="所属城市ID" align="center" prop="cityId" />-->
      <el-table-column label="发布类型" align="center" prop="releaseType" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.announce_type" :value="scope.row.releaseType"/>
        </template>
      </el-table-column>
<!--      <el-table-column label="浏览量" align="center" prop="pageView" />
      <el-table-column label="是否收藏0否1是" align="center" prop="collectState" />
      <el-table-column label="是否明星推荐0否1是" align="center" prop="recState" />
      <el-table-column label="预定状态0未预定1已预定" align="center" prop="reserveState" />
      <el-table-column label="VR资源" align="center" prop="vrResource" />
      <el-table-column label="明星推荐状态0否1是" align="center" prop="recomState">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.recomState"/>
        </template>
      </el-table-column>
      <el-table-column label="图片资源" align="center" prop="imgResource" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.imgResource" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="封面资源http:p1" align="center" prop="coverResource" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.coverResource" :width="50" :height="50"/>
        </template>
      </el-table-column>-->
      <el-table-column label="联系人" align="center" prop="contactName" />
<!--      <el-table-column label="联系方式" align="center" prop="servicePhone" />-->
      <el-table-column label="联系方式" align="center" prop="contactPhone" />
<!--      <el-table-column label="发布人用户ID" align="center" prop="supplyUserId" />-->
      <el-table-column label="审核" align="center" prop="approvalState" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.audit_status" :value="scope.row.approvalState"/>
        </template>
      </el-table-column>
<!--      <el-table-column label="审核备注" align="center" prop="approvalNote" />
      <el-table-column label="园区ID" align="center" prop="parkId" />
      <el-table-column label="备注" align="center" prop="note" />
      <el-table-column label="排序" align="center" prop="sort" />
      <el-table-column label="状态0有效1失效" align="center" prop="state" />
      <el-table-column label="是否删除0否1是" align="center" prop="dr" />
      <el-table-column label="vr封面" align="center" prop="vrcover" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.vrcover" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="是否置顶0：否1：是" align="center" prop="top">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.top"/>
        </template>
      </el-table-column>-->
      <el-table-column width="220" label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
        <template slot-scope="scope">
          <el-row>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-view"
              @click="handleLook(scope.row)"
            >预览
            </el-button>
              <el-button
                style=""
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row)"
                v-hasPermi="['myIndustry:apartment:edit']"
              >修改</el-button>
<!--            <el-button-->
<!--              style=""-->
<!--              size="mini"-->
<!--              type="text"-->
<!--              icon="el-icon-edit"-->
<!--              v-if="scope.row.approvalState===0"-->
<!--              @click="spaceAudit(scope.row)"-->
<!--              v-hasPermi="['myIndustry:apartment:edit']"-->
<!--            >审核-->
<!--            </el-button>-->
              <el-button
              style=""
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['myIndustry:apartment:remove']"
            >删除</el-button>
<!--            <el-col :span="1.5">-->
<!--              <el-button-->
<!--                type="warning"-->
<!--                plain-->
<!--                icon="el-icon-download"-->
<!--                size="mini"-->
<!--                @click="handleExport"-->
<!--                v-hasPermi="['myIndustry:apartment:export']"-->
<!--              >导出-->
<!--              </el-button>-->
<!--            </el-col>-->
          </el-row>

        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改公寓对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="759px" :close-on-click-modal="false" append-to-body center>
      <el-form ref="form" :model="form" :rules="rules" label-width="130px" style="margin-left: 2%; margin-right: 2%">
        <el-form-item label="公寓名称" prop="apartmentName" >
          <el-input v-model="form.apartmentName" placeholder="请输入空间名称" maxlength="100" class="apartment"/>
        </el-form-item>

        <el-row>
          <el-col :span="24">
            <el-form-item label="需求类型" prop="supplyType">
              <el-checkbox-group v-model="form.supplyType" class="apartment">
                <el-checkbox
                  v-for="dict in dict.type.need_mode"
                  :key="dict.value"
                  :label="dict.value">
                  {{ dict.label }}
                </el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
<!--          <el-col :span="24">-->
<!--            <el-form-item label="发布类型" prop="releaseType">-->
<!--              <el-select v-model="form.releaseType" placeholder="请选择发布类型"-->
<!--                         @change='updateRelease(form.releaseType)' class="apartment">-->
<!--                <el-option-->
<!--                  v-for="dict in dict.type.announce_type"-->
<!--                  :key="dict.value"-->
<!--                  :label="dict.label"-->
<!--                  :value="parseInt(dict.value)"-->
<!--                />-->
<!--              </el-select>-->
<!--            </el-form-item>-->
<!--          </el-col>-->
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item :label="form.releaseType===0?'租赁价格':'预算'" prop="apartmentLeasePrice">
              <el-input v-model="form.apartmentLeasePrice" maxlength="100"
                        oninput="value=value.replace(/[^0-9.]/g,'')"
                        :placeholder="form.releaseType===0?'请输入租赁价格':'请输入预算价格'"
                        class="apartment">
                <template slot="append">元/m²/天</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item :label="form.releaseType===0?'出售价格':'预期价格'" prop="apartmentSellPrice">
              <el-input v-model="form.apartmentSellPrice" maxlength="100"
                        oninput="value=value.replace(/[^0-9.]/g,'')"
                        :placeholder="form.releaseType===0?'请输入出售价格':'请输入预期价格'"
                        class="apartment">
                <template slot="append">元/m²</template>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="建筑总面积" prop="apartmentAllSize" >
              <el-input v-model="form.apartmentAllSize" maxlength="100" @change="handleAcreage" oninput="value=value.replace(/[^0-9.]/g,'')"
                        placeholder="请输入建筑总面积" class="apartment">
                <template slot="append">m²</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="空置面积" prop="apartmentFreeSize" >
              <el-input v-model="form.apartmentFreeSize" maxlength="100" @change="handleAcreage" oninput="value=value.replace(/[^0-9.]/g,'')"
                        placeholder="请输入空置面积" class="apartment">
                <template slot="append">元/m²</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="需求面积" prop="apartmentNeedSize" @change="handleAcreage" v-if="form.releaseType===1">
              <el-input v-model="form.apartmentNeedSize" maxlength="100" oninput="value=value.replace(/[^0-9.]/g,'')"
                        placeholder="请输入需求面积" class="apartment"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-col :span="24">
          <el-form-item>
            <el-alert
              class="apartment" title="空置面积大于总面积" v-if="acreage1<0" :closable="false" type="error" center show-icon>
            </el-alert>
          </el-form-item>
        </el-col>
        <el-row>
          <el-col :span="24">
            <el-form-item label="公寓楼号" prop="apartmentNumber">
              <el-input v-model="form.apartmentNumber" maxlength="100" placeholder="请输入公寓楼号" class="apartment"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="单间公寓面积" prop="apartmentRoomSize">
              <el-input v-model="form.apartmentRoomSize" maxlength="100" placeholder="请输入单间公寓面积" class="apartment"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item>
              <el-alert
                class="apartment" title="单间公寓面积大于总面积" v-if="acreage<0" :closable="false" type="error" center show-icon>
              </el-alert>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="户型" prop="apartmentHouse">
              <el-select v-model="form.apartmentHouse" placeholder="请选择户型" class="apartment">
                <el-option
                  v-for="dict in dict.type.park_apartment"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="朝向" prop="apartmentDirection">
              <el-select v-model="form.apartmentDirection" placeholder="请输入朝向" class="apartment">
                <el-option label="东" value="1"></el-option>
                <el-option label="南" value="2"></el-option>
                <el-option label="西" value="3"></el-option>
                <el-option label="北" value="4"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="装修程度" prop="apartmentRenova">
              <el-select v-model="form.apartmentRenova" placeholder="请选择装修程度" class="apartment">
                <el-option
                  v-for="dict in dict.type.degree_of_decoration"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="客梯" prop="apartmentElevatorPeople">
              <el-radio-group v-model="form.apartmentElevatorPeople" class="apartment">
                <el-radio :label="'有-'">
                  有
                  <input class="sq" style="width: 50px" maxlength="100" oninput="value=value.replace(/[^0-9]/g,'')"
                         v-model="otherElevatorPeople"/>
                  部
                </el-radio>
                <el-radio label="无">无</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="客梯负载" prop="apartmentElevatorPeopleLoad">
              <el-input v-model="form.apartmentElevatorPeopleLoad" maxlength="100"
                        oninput="value=value.replace(/[^0-9.]/g,'')"
                        placeholder="请输入客梯负载" class="apartment">
                <template slot="append">kg</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="货梯" prop="apartmentElevatorCargo">
              <el-radio-group v-model="form.apartmentElevatorCargo" class="apartment">
                <el-radio :label="'有-'">
                  有
                  <input class="sq" style="width: 50px" maxlength="100" oninput="value=value.replace(/[^0-9]/g,'')"
                         v-model="otherElevatorCargo"/>
                  部
                </el-radio>
                <el-radio label="无">无</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="货梯负载" prop="apartmentElevatorCargoLoad">
              <el-input v-model="form.apartmentElevatorCargoLoad"
                        oninput="value=value.replace(/[^0-9.]/g,'')" maxlength="100"
                        placeholder="请输入货梯负载" class="apartment">
                <template slot="append">kg</template>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="消防设施" prop="apartmentFireControl">
              <el-checkbox-group v-model="form.apartmentFireControl" class="apartment">
                <el-checkbox
                  v-for="dict in dict.type.fire_fighting_device"
                  :key="dict.value"
                  :label="dict.value">
                  {{ dict.label }}
                </el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="应急系统" prop="apartmentEmergency">
              <el-radio-group v-model="form.apartmentEmergency" class="apartment">
                <el-radio
                  v-for="dict in dict.type.sys_have_not"
                  :key="dict.value"
                  :label="dict.value"
                >{{ dict.label }}
                </el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="供暖" prop="apartmentHeating">
              <el-select v-model="form.apartmentHeating" placeholder="请选择供暖" class="apartment">
                <el-option
                  v-for="dict in dict.type.heating_system"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="制冷" prop="apartmentRefrig">
              <el-select v-model="form.apartmentRefrig" placeholder="请选择制冷" class="apartment">
                <el-option
                  v-for="dict in dict.type.refrigerating_system"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="新风系统" prop="apartmentNather">
              <el-select v-model="form.apartmentNather" placeholder="请选择新风系统" class="apartment">
                <el-option
                  v-for="dict in dict.type.sys_have_not"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="电量" prop="apartmentPower">
              <el-input v-model="form.apartmentPower" maxlength="100" placeholder="请输入电量" class="apartment">
                <template slot="append">度</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="燃气" prop="apartmentGas">
                <el-radio-group v-model="form.apartmentGas" class="workshop">
                  <el-radio
                    v-for="dict in dict.type.gas_system"
                    :key="dict.value"
                    :label="dict.value"
                  >{{ dict.label }}
                  </el-radio>
                </el-radio-group>
              <input v-if="form.apartmentGas==='其他-'" class="sq" v-model="otherGas" style="width: 20%"
                     placeholder="请输入其他燃气类型"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="供水" prop="apartmentWater">
              <el-select v-model="form.apartmentWater" placeholder="请选择供水" class="apartment">
                <el-option
                  v-for="dict in dict.type.water_system"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="周边交通" prop="apartmentTraffic">
              <el-input v-model="form.apartmentTraffic" maxlength="100" placeholder="请输入周边交通" class="apartment"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="期望地段" prop="parkAreaAddress">
              <el-select v-model="form.parkAreaAddress" placeholder="请选择期望地段" class="apartment">
                <el-option
                  v-for="dict in dict.type.regional_position"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="公交" prop="parkBus">
              <el-select v-model="form.parkBus" placeholder="请选择公交" class="apartment">
                <el-option
                  v-for="dict in dict.type.traffic_distance"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="地铁" prop="parkMetro">
              <el-select v-model="form.parkMetro" placeholder="请选择地铁" class="apartment">
                <el-option
                  v-for="dict in dict.type.traffic_distance"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
        <el-form-item label="关联园区" prop="parkId">
          <el-select v-model="form.parkId" filterable remote placeholder="请输入关联园区"
                     class="workshop">
            <el-option v-for="dict in parkList" :key="dict.id"
                       :label="dict.parkName" :value="dict.id">
            </el-option>
          </el-select>
        </el-form-item>
          </el-col>
          <el-col :span="24">
        <el-form-item label="所属城市" prop="cityId">
          <el-select v-model="form.provinceId" placeholder="请选择省份" style="width: 45%"
                     @change="getCityList(form.provinceId)" clearable >
            <el-option
              v-for="dict in provinces"
              :key="dict.id"
              :label="dict.name"
              :value="dict.id"
            />
          </el-select>
          <el-select v-model="form.cityId" placeholder="请选择城市"
                     :disabled="form.provinceId==null||form.provinceId===''"
                     style="width: 45%" clearable>
            <el-option
              v-for="dict in citys"
              :key="dict.id"
              :label="dict.name"
              :value="dict.id"
            />
          </el-select>
        </el-form-item>
          </el-col>
        </el-row>

<!--        <el-row>
          <el-col :span="24">
            <el-form-item label="浏览量" prop="pageView">
              <el-input v-model="form.pageView" placeholder="请输入浏览量"
                        oninput="value=value.replace(/[^0-9]/g,'')"
                        class="apartment"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="收藏" prop="collectState">
              <el-select v-model="form.collectState" placeholder="请选择是否收藏" class="apartment">
                <el-option
                  v-for="dict in dict.type.sys_whether"
                  :key="dict.value"
                  :label="dict.label"
                  :value="parseInt(dict.value)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="热门推荐状态" prop="recState">
              <el-select v-model="form.recState" placeholder="热门推荐状态" class="apartment">
                <el-option
                  v-for="dict in dict.type.recommend"
                  :key="dict.value"
                  :label="dict.label"
                  :value="parseInt(dict.value)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="明星推荐状态" prop="recomState">
              <el-select v-model="form.recomState" placeholder="明星推荐状态" class="apartment">
                <el-option
                  v-for="dict in dict.type.recommend"
                  :key="dict.value"
                  :label="dict.label"
                  :value="parseInt(dict.value)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="置顶" prop="top">
              <el-select v-model="form.top" placeholder="请选择是否置顶" class="apartment">
                <el-option
                  v-for="dict in dict.type.sys_whether"
                  :key="dict.value"
                  :label="dict.label"
                  :value="parseInt(dict.value)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="预定状态" prop="reserveState">
              <el-select v-model="form.reserveState" placeholder="请输入预定状态" class="apartment">
                <el-option
                  v-for="dict in dict.type.reserve_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="parseInt(dict.value)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>-->

        <el-form-item label="vr封面" prop="vrcover">
          <image-upload v-model="form.vrcover" :limit="1"/>
        </el-form-item>
        <el-form-item label="VR资源" prop="vrResource">
<!--          <file-upload v-model="form.vrResource"/>-->
          <video-upload v-model="form.vrResource"/>
        </el-form-item>
        <el-form-item label="微信二维码" prop="qrCode">
          <image-upload v-model="form.qrCode" :limit="1"/>
        </el-form-item>
        <el-form-item label="图片资源" prop="imgResource">
          <image-upload v-model="form.imgResource"/>
        </el-form-item>
        <el-form-item label="封面资源" prop="coverResource">
          <image-upload v-model="form.coverResource" :limit="1"/>
        </el-form-item>

        <el-row>
          <el-col :span="24">
            <el-form-item label="联系人" prop="contactName">
              <el-input v-model="form.contactName" maxlength="100" placeholder="请输入联系人" class="apartment"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="联系方式" prop="contactPhone">
              <el-input v-model="form.contactPhone" placeholder="请输入联系方式" class="apartment"/>
            </el-form-item>
          </el-col>
        </el-row>
<!--        <el-form-item label="联系方式" prop="contactPhone">
          <el-input v-model="form.contactPhone" placeholder="请输入联系方式" />
        </el-form-item>-->
<!--        <el-form-item label="发布人用户ID" prop="supplyUserId">
          <el-input v-model="form.supplyUserId" placeholder="请输入发布人用户ID" />
        </el-form-item>
        <el-form-item label="审核意见" prop="approvalNote">
          <el-input v-model="form.approvalNote" placeholder="请输入审核意见" />
        </el-form-item>
        <el-form-item label="审核状态" prop="approvalState">
          <el-select v-model="form.approvalState" placeholder="请输入审核状态">
            <el-option
              v-for="dict in dict.type.audit_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>-->

        <el-form-item label="备注" prop="note">
          <el-input v-model="form.note" type="textarea" maxlength="100" show-word-limit placeholder="请输入备注" class="apartment"/>
        </el-form-item>
        <el-form-item >
          <el-alert
            title="初审通过" type="success" center :closable="false" v-if="form.approvalState===1||form.approvalState===3||form.approvalState===4" class="apartment" show-icon>
          </el-alert>
          <el-alert
            title="初审拒绝" type="error" center :closable="false" v-if="form.approvalState===2" class="apartment" show-icon>
          </el-alert>
        </el-form-item>
        <el-form-item label="初审意见" prop="approvalNote" v-if="form.approvalState!==0&&form.approvalState!=null">
          <editor v-model="form.approvalNote" :min-height="100" class="apartment" read-only/>
        </el-form-item>
        <el-form-item>
          <el-alert title="复审通过" type="success" center :closable="false" v-if="form.approvalState===1" class="apartment" show-icon>
          </el-alert>
          <el-alert title="复审拒绝" type="error" center :closable="false" v-if="form.approvalState===4" class="apartment" show-icon>
          </el-alert>
        </el-form-item>
        <el-form-item label="复审意见" prop="recheckNote" v-if="form.approvalState===1||form.approvalState===4">
          <editor v-model="form.recheckNote" :min-height="100" class="apartment" read-only/>
        </el-form-item>
<!--        <el-form-item label="排序" prop="sort">
          <el-input v-model="form.sort" placeholder="请输入排序" />
        </el-form-item>-->
<!--        <el-form-item label="状态" prop="state">
          <el-select v-model="form.state" placeholder="请选择是否生效">
            <el-option
              v-for="dict in dict.type.sys_yes_no"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label === '是' ? 1 : 0"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="删除状态" prop="dr">
          <el-select v-model="form.dr" placeholder="请输入是否删除">
            <el-option
              v-for="dict in dict.type.sys_yes_no"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label === '是' ? 1 : 0"
            ></el-option>
            </el-select>
        </el-form-item>-->

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 审核 -->
    <el-dialog title="厂房审核" :visible.sync="apartmentAudit" close-on-click-modal center width="750px">
      <el-form :model="form" label-width="130px">
        <el-form-item label="审核意见" prop="approvalNote">
          <Editor v-model="form.approvalNote" :min-height="100" style="width: 85%"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="success" @click="submitCheck(1)">审核通过</el-button>
        <span style="width: 5%;display: inline-block"></span>
        <el-button type="danger" @click="submitCheck(2)">审核驳回</el-button>
        <span style="width: 5%;display: inline-block"></span>
        <el-button type="info" @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listApartment, getApartment, delApartment, addApartment, updateApartment } from "@/api/myIndustry/apartment";
import {listCity} from "@/api/business/businessIntro";
import {parkList} from "@/api/myIndustry/park";
import VideoUpload from "@/components/VideoUpload";
import MyEditor from "@/components/wangEdiot";

export default {
  name: "Apartment",
  components: {MyEditor, VideoUpload},
  dicts: ['sys_have_not', 'audit_status','recommend', 'park_type','regional_position','reserve_type','sys_whether', 'rental_price', 'heating_system', 'industry_orientation', 'traffic_distance', 'degree_of_decoration','announce_type', 'park_apartment', 'need_mode', 'sys_yes_no', 'refrigerating_system', 'gas_system', 'fire_fighting_device', 'water_system'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      //省份
      provinces: [],
      //城市
      citys: [],
      //园区列表
      parkList: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      //审核弹窗
      apartmentAudit: false,
      //客梯数量
      otherElevatorPeople: null,
      //货梯数量
      otherElevatorCargo: null,
      //其他燃气
      otherGas: null,
      // 总条数
      total: 0,
      // 公寓表格数据
      apartmentList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,

      acreage: 0,
      acreage1: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        apartmentName: null,
        supplyType: null,
        apartmentLeasePrice: null,
        apartmentSellPrice: null,
        apartmentAllSize: null,
        apartmentFreeSize: null,
        apartmentNumber: null,
        apartmentRoomSize: null,
        apartmentHouse: null,
        apartmentDirection: null,
        apartmentRenova: null,
        apartmentElevatorPeople: null,
        apartmentElevatorPeopleLoad: null,
        apartmentElevatorCargo: null,
        apartmentElevatorCargoLoad: null,
        apartmentFireControl: null,
        apartmentEmergency: null,
        apartmentHeating: null,
        apartmentRefrig: null,
        apartmentNather: null,
        apartmentPower: null,
        apartmentGas: null,
        apartmentWater: null,
        apartmentNeedSize: null,
        apartmentTraffic: null,
        parkType: null,
        parkAreaAddress: null,
        parkBus: null,
        parkMetro: null,
        cityId: null,
        releaseType: 1,
        pageView: null,
        collectState: null,
        recState: null,
        reserveState: null,
        vrResource: null,
        recomState: null,
        imgResource: null,
        coverResource: null,
        contactName: null,
        servicePhone: null,
        contactPhone: null,
        supplyUserId: null,
        approvalState: null,
        approvalNote: null,
        parkId: null,
        note: null,
        sort: null,
        state: null,
        dr: null,
        vrcover: null,
        top: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        apartmentName: [
          { required: true, message: "空间名称不能为空", trigger: "blur" }
        ],
        supplyType: [
          { required: true, message: "需求类型不能为空", trigger: "blur" }
        ],
        apartmentLeasePrice: [
          { required: true, message: "预算价格不能为空", trigger: "blur" }
        ],
        apartmentSellPrice: [
          { required: true, message: "预期价格不能为空", trigger: "blur" }
        ],
        releaseType: [
          { required: true, message: "发布类型不能为空", trigger: "blur" }
        ],
        contactName: [
          {required: true, message: "联系人不能为空", trigger: "blur"}
        ],
        contactPhone: [
          {required: true, message: "联系方式不能为空", trigger: "blur"},
          {
            required: true,
            pattern: /^[1][3,4,5,7,8,9][0-9]{9}$/,
            message: '请输入正确的手机号码',
            trigger: 'blur',
          },
        ],
        // apartmentAllSize: [
        //   {required: true, message: "建筑总面积不能为空", trigger: "blur"}
        // ],
        cityId: [
          {required: true, message: "所属城市不能为空", trigger: "blur"}
        ],
        // coverResource: [
        //   {required: true, message: "封面资源不能为空", trigger: "blur"}
        // ],
        // imgResource: [
        //   {required: true, message: "图片资源不能为空", trigger: "blur"}
        // ],
        // apartmentRoomSize: [
        //   {required: true, message: "单间公寓面积不能为空", trigger: "blur"}
        // ],
        // parkId: [
        //   {required: true, message: "关联园区不能为空", trigger: "blur"}
        // ],
        // releaseType: [
        //   { required: true, message: "发布类型不能为空", trigger: "blur" }
        // ],
      }
    };
  },
  created() {
    this.getList();
    this.getprovinceList();
  },
  methods: {
    //预览
    handleLook(row) {
      //http://120.46.220.152/#/pages/index/details?id=339&buildType=4&spaceId=dc46adbfb2944da39078f61446cd662f&provinceId=34
      // window.location.href=`http://120.46.220.152/#/pages/news/details?id=`+id
      open(`http://120.46.220.152/#/pages/index/details?id=`+row.id+`&buildType=6&spaceId=` + row.serialNumber + `&provinceId=` + row.provinceId)
    },
    //面积
    handleAcreage(){
      if (this.form.apartmentAllSize!=null&&this.form.apartmentRoomSize!=null){
        this.acreage = this.form.apartmentAllSize-this.form.apartmentRoomSize
      }
      if (this.form.apartmentAllSize!=null&&this.form.apartmentFreeSize!=null){
        // if (this.form.apartmentRoomSize!=null){
        //   this.acreage1 = this.form.apartmentAllSize-this.form.apartmentFreeSize-this.form.apartmentRoomSize
        // }else {
        this.acreage1 = this.form.apartmentAllSize-this.form.apartmentFreeSize
        // }
      }
    },

    /** 查询公寓列表 */
    getList() {
      this.loading = true;
      listApartment(this.queryParams).then(response => {
        this.apartmentList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.apartmentAudit = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.otherElevatorPeople = null;
      this.otherElevatorCargo = null;
      this.otherGas = null;
      this.form = {
        id: null,
        apartmentName: null,
        supplyType: [],
        apartmentLeasePrice: null,
        apartmentSellPrice: null,
        apartmentAllSize: null,
        apartmentFreeSize: null,
        apartmentNumber: null,
        apartmentRoomSize: null,
        apartmentHouse: null,
        apartmentDirection: null,
        apartmentRenova: null,
        apartmentElevatorPeople: null,
        apartmentElevatorPeopleLoad: null,
        apartmentElevatorCargo: null,
        apartmentElevatorCargoLoad: null,
        apartmentFireControl: [],
        apartmentEmergency: null,
        apartmentHeating: null,
        apartmentRefrig: null,
        apartmentNather: null,
        apartmentPower: null,
        apartmentGas: null,
        apartmentWater: null,
        apartmentNeedSize: null,
        apartmentTraffic: null,
        parkType: null,
        parkAreaAddress: null,
        parkBus: null,
        parkMetro: null,
        cityId: null,
        releaseType: 1,
        pageView: null,
        collectState: null,
        recState: null,
        reserveState: null,
        vrResource: null,
        recomState: null,
        imgResource: null,
        coverResource: null,
        contactName: null,
        servicePhone: null,
        contactPhone: null,
        supplyUserId: null,
        approvalState: null,
        approvalNote: null,
        parkId: null,
        note: null,
        sort: null,
        state: null,
        dr: null,
        createTime: null,
        updateTime: null,
        vrcover: null,
        top: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      if (this.$store.getters.checkState==='0'){
        this.$message({
          type: 'info',
          message: `用户信息审核中`
        });
        return
      }else if (this.$store.getters.checkState==='2'){
        this.$message({
          type: 'error',
          message: `用户信息审核失败`
        });
        return
      }else if (this.$store.getters.checkState=== '-1'){
        this.$message({
          type: 'info',
          message: `用户信息未提交`
        });
        return
      }
      this.reset();
      console.log(this.form)
      this.getParkList();
      this.open = true;
      this.title = "添加公寓";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      console.log(this.form)
      const id = row.id || this.ids
      this.getParkList();
      getApartment(id).then(response => {
        this.form = response.data;
        this.form.supplyType = this.form.supplyType.split(",");
        this.form.apartmentFireControl = this.form.apartmentFireControl.split(",");
        // this.form.apartmentGas = this.form.apartmentGas.split(",");
        //客梯
        if (response.data.apartmentElevatorPeople != null && response.data.apartmentElevatorPeople.indexOf("有-") !== -1) {
          this.otherElevatorPeople = response.data.apartmentElevatorPeople
          this.otherElevatorPeople = this.otherElevatorPeople.substring(this.otherElevatorPeople.indexOf("有-") + 2)
          this.form.apartmentElevatorPeople = this.form.apartmentElevatorPeople.substring(0, this.form.apartmentElevatorPeople.indexOf("有-") + 2)
        }
        //货梯
        if (response.data.apartmentElevatorCargo != null && response.data.apartmentElevatorCargo.indexOf("有-") !== -1) {
          this.otherElevatorCargo = response.data.apartmentElevatorCargo
          this.otherElevatorCargo = this.otherElevatorCargo.substring(this.otherElevatorCargo.indexOf("有-") + 2)
          this.form.apartmentElevatorCargo = this.form.apartmentElevatorCargo.substring(0, this.form.apartmentElevatorCargo.indexOf("有-") + 2)
        }
        //燃气
        if (response.data.apartmentGas != null && response.data.apartmentGas.includes("其他-")) {
          this.otherGas = response.data.apartmentGas
          this.form.apartmentGas = this.form.apartmentGas.substring(0, response.data.apartmentGas.indexOf("其他-") + 3);
          this.otherGas = this.otherGas.substring(this.otherGas.indexOf("其他-") + 3);
        }
        //城市
        if (response.data.provinceId != null && response.data.provinceId !== '') {
          listCity(response.data.provinceId).then(rest => {
            this.citys = rest.data;
          })
        }
        this.open = true;
        this.title = "修改公寓";
      });
    },
    /** 审核 */
    spaceAudit(row) {
      this.reset();
      this.form.id = row.id
      this.apartmentAudit = true;
    },
    /** 提交审核 */
    submitCheck(state) {
      updateApartment({
        id: this.form.id,
        approvalState: state,
        approvalNote: this.form.approvalNote
      }).then(response => {
        this.$modal.msgSuccess("审核成功");
        this.apartmentAudit = false;
        this.getList();
      });

    },
    //更改发布类型
    updateRelease(releaseType) {
      if (this.form.releaseType===0){
        this.form.apartmentNeedSize = null;
      } else {
        this.form.apartmentAllSize = null;
        this.form.apartmentFreeSize = null;
      }
    },
    /** 提交按钮 */
    submitForm() {
      if (this.acreage<0||this.acreage1<0){
        this.$alert('还有未处理的警告，请处理完相关问题后提交', '警告', {
          confirmButtonText: '确定',
          callback: action => {
            this.$message({
              type: 'info',
              message: `处理完相关问题后再提交`
            });
          }
        })
        return
      }
      this.$refs["form"].validate(valid => {
        if (valid) {
          //客梯
          if (this.form.apartmentElevatorPeople === "有-"&&(this.otherElevatorPeople==null||this.otherElevatorPeople==='')) {
            $modal.msgError("请填写客梯数量");
            return
          }
          //货梯
          if (this.form.apartmentElevatorCargo === "有-"&&(this.otherElevatorCargo==null||this.otherElevatorCargo==='')) {
            $modal.msgError("请填写货梯数量");
            return;
          }
          //燃气
          if (this.form.apartmentGas === "其他-"&&(this.otherGas==null||this.otherGas==='')) {
            $modal.msgError("请输入其他燃气种类");
            return;
          }
          this.form.supplyType = this.form.supplyType.join(",");
          this.form.apartmentFireControl = this.form.apartmentFireControl.join(",");
          // this.form.apartmentGas = this.form.apartmentGas.join(",");
          //客梯
          if (this.form.apartmentElevatorPeople === "有-") {
            this.form.apartmentElevatorPeople = this.form.apartmentElevatorPeople + this.otherElevatorPeople
          }
          //货梯
          if (this.form.apartmentElevatorCargo === "有-") {
            this.form.apartmentElevatorCargo = this.form.apartmentElevatorCargo + this.otherElevatorCargo
          }
          //燃气
          if (this.form.apartmentGas === "其他-") {
            this.form.apartmentGas = this.form.apartmentGas + this.otherGas
          }
          // this.form.approvalState = 0
          if (this.form.id != null) {
            updateApartment(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addApartment(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除公寓编号为"' + ids + '"的数据项？').then(function() {
        return delApartment(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('industry/frontend/apartment/export', {
        ...this.queryParams
      }, `apartment_${new Date().getTime()}.xlsx`)
    },
    //获取省份
    getprovinceList(){
      var parentId = 0;
      listCity(parentId).then(res =>{
        // console.log("AAA",res)
        this.provinces = res.data;
      })
    },
    //查询市列表
    getCityList(provinceId) {
      console.log("BBB",provinceId)
      listCity(provinceId).then(res =>{
        this.citys = res.data;
      })
    },
    //获取园区id
    getParkList() {
      parkList().then(res => {
        // console.log(res)
        this.parkList = res.data;
      })
    }
  }
};
</script>
<style>
.apartment {
  width: 90%;
}
.sq {
  width: 25px;
  margin: 0 10px;
  border: none;
  border-bottom: 1px solid;
}
/*.float-centered{
  display: flex;
  justify-content: stretch;
  flex-wrap: wrap;
  margin-left: 253px;
}
.el-form-item {
  margin-top: 20px;
}
.pagination-container[data-v-72233bcd] {
  display: flex;
  justify-content: center;
}
.el-form-item {
  width: 600px;
}
.el-input__inner{
  width: 250px;
}*/
</style>
